Skip to content

Conversation

@reivilibre
Copy link
Contributor

@reivilibre reivilibre commented Oct 22, 2025

Part of: #4492

Revoke both personal sessions that are owned by, and acting as, the deactivated user.

Owned by because: it doesn't make sense for a deactivated user to be able to control themselves or other users, so them having active personal sessions is just confusing.

Acting as because: current precedent is that deactivated users are not controllable, even by admins.
To uphold this, the admin API is also fixed to stop allowing the creation of personal sessions for deactivated users.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 22, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 409f354
Status: ✅  Deploy successful!
Preview URL: https://3a983a49.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://rei-pat-revoke-on-deactivate.matrix-authentication-service-docs.pages.dev

View logs

@reivilibre reivilibre marked this pull request as ready for review October 22, 2025 11:07
@reivilibre reivilibre requested a review from sandhose October 22, 2025 11:07
let status = match self {
Self::Internal(_) => StatusCode::INTERNAL_SERVER_ERROR,
Self::UserNotFound => StatusCode::NOT_FOUND,
Self::UserDeactivated => StatusCode::GONE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure why not :D

.await?
.ok_or(RouteError::UserNotFound)?;

if actor_user.deactivated_at.is_some() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe check just is_valid (assuming it does the right thing) so that we also check for locked status?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now using is_valid_actor

.table(PersonalSessions::Table)
.value(PersonalSessions::RevokedAt, revoked_at)
.and_where(
Expr::col((PersonalSessions::Table, PersonalSessions::PersonalSessionId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a chunky subquery. I assume you need this because of the JOIN; could you stick in a comment explaining that? Also we could be doing that in a CTE, but not convinced the code would be clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some comments

yeah, it's a bit chunky, the sea-query doesn't help with that verbosity either, but hopefully the new comments make the intent clear

@reivilibre reivilibre requested a review from sandhose October 22, 2025 13:23
@reivilibre reivilibre merged commit 0d28304 into main Oct 22, 2025
20 checks passed
@reivilibre reivilibre deleted the rei/pat_revoke_on_deactivate branch October 22, 2025 13:53
@sandhose sandhose added the T-Enhancement New feature of request label Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Enhancement New feature of request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants